package com.lin.pay.wx.sdk;

import com.lin.common.error.CustomRuntimeException;
import com.lin.common.error.ErrorCode;
import org.springframework.beans.factory.annotation.Value;

import java.util.Map;
import java.util.UUID;

public class ReqMapInit {
    @Value("${wdp.wx.appid}")
    private String wxappid;
    @Value("${wdp.wx.mch_id}")
    private String wxmchid;

    public Map<String,String> initWxMap(Map<String,String> map) throws CustomRuntimeException {
        if(map==null){
            throw new CustomRuntimeException(ErrorCode.MAP_NON_EXISTENT, ErrorCode.MAP_NON_EXISTENT.getMessage());
        }
        map.put("appid",wxappid);
        map.put("mch_id",wxmchid);
        map.put("nonce_str", UUID.randomUUID().toString().replace("-", ""));

        return map;
    }
}
